package com.shell.provider;

import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.esign.service.EsignAuthService;
import com.shell.bee.esign.vo.EsignAuthResponse;
import com.shell.bee.esign.vo.TelecomAuthRequest;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EsignAcctTxProvider {
	@Autowired
	private EsignAuthService esignAuthService;

	@RequestMapping({ "/saveEsignCust" })
	public Map<String, String> saveEsignCust(String userId, String userName, String phoneNo, String idNo) {
		if ((StringUtil.notEmpty(userName)) && (StringUtil.notEmpty(phoneNo)) && (StringUtil.notEmpty(idNo))) {
			Map<String, String> ret = new HashMap();
			TelecomAuthRequest request = new TelecomAuthRequest();
			request.setName(userName);
			request.setIdno(idNo);
			request.setMobile(phoneNo);
			EsignAuthResponse response = null;
			String msg = null;
			try {
				response = this.esignAuthService.telecomAuth(request);
				if (response != null) {
					msg = response.getMsg();
				}
			} catch (Exception e) {
				e.printStackTrace();
				msg = e.getMessage();
			}
			ret.put("errorCode", String.valueOf(response.getErrCode()));
			ret.put("msg", msg);
			return ret;
		}
		return null;
	}
}
